<template>

	<div>

		<el-form  :model="form" label-width="150px">
<!--		  <el-form-item label="类型Id">-->
<!--		    <el-input v-model="form.typeId" readonly></el-input>-->
<!--		  </el-form-item>-->
      <el-form-item label="检查项目名称">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
		  <el-form-item label="价格">
		    <el-input v-model="form.price"></el-input>
		  </el-form-item>
		  <el-form-item>
		    <el-button type="primary" @click="save()">保存</el-button>

		  </el-form-item>
		</el-form>



	</div>

</template>

<script>
	import {getForm,save,update} from "@/api/item_manager/checkitem";
  export default{
		name:'DeptEdid',
		props:["id"],
		data(){
			return {
				form:{
          checkId:'',
          name:'',
          price:'',
				}
			}
		},
		created() {
			if(this.id){
				this.getForm();
			}
		},
		methods:{
			//修改的时候初始化使用
			getForm(){
        getForm(this.id).then((form) =>{
           this.form = form;
      }).catch((e)=>{
        console.log("失败的情况",e)
      });

			},
			save(){
				let promise  =  null;

        // delete  this.form.createtime;

        if(this.id) {
          promise = update( this.form);
        }else{
          promise = save( this.form);
        }
				// form /
        promise.then((success) =>{
					 if(success){
						 this.$message.success("保存成功");
						 //关掉自己
						 this.$emit("update:visible",false);
						 this.$emit("close");
					 }
				}).catch((e)=>{
					console.log("失败的情况",e)
				});

			}
		}
	}


</script>

<style scoped>




</style>
